package com.atguigu.edustatistics.controller;


import com.atguigu.commonutils.Result;
import com.atguigu.edustatistics.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author 董万均
 * @since 2020-11-08
 */
@RestController
@RequestMapping("/edustatistics/statistics")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    //将注册的人数添加到拎一个表中
    @PostMapping("registerCount/{day}")
    public Result registerCount(@PathVariable String day){
        dailyService.registerCount(day);
        return Result.ok();
    }
    //为了显示图表，根据统计的类型，统计的时间间隔
    @GetMapping("showChart/{type}/{begin}/{end}")
    public Result showChart(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        //前端只接收json格式，所以使用map
        Map<String,Object> map=dailyService.showChart(type,begin,end);
        return Result.ok().data(map);
    }
}

